/**
 *
 */
package com.naiterui.ehp.bs.doctor.repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bp.domain.Hospital;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description 医院持久层实现类
 */
@Repository
public interface IHospitalRepository extends BaseJpaRepository<Hospital, Integer> {

    List<Hospital> findByNameLikeAndHideOrderByCreatedAtDesc(String name, int hide);

    @Query(value = "select t.* from dr_hospital t where t.name like ?1 and t.hide=?2 order by t.created_at desc limit ?3", nativeQuery = true)
    List<Hospital> findByNameLikeAndHideLimit(String name, int hide, Integer limit);

    List<Hospital> findByCityIdAndHideOrderByChangedAtDesc(Integer cityId, int hide);

    @Query(value = "select t.* from dr_hospital t where t.city_id=?1 and t.hide=?2 order by t.changed_at desc limit ?3", nativeQuery = true)
    List<Hospital> findByCityIdAndHideLimit(Integer cityId, int hide, Integer limit);

    List<Hospital> findByCityIdInAndHideOrderByChangedAtDesc(List<Integer> cityIds, int hide);

    @Query(value = "select t.* from dr_hospital t where t.city_id in (?1) and t.hide=?2 order by t.changed_at desc limit ?3", nativeQuery = true)
    List<Hospital> findByCityIdAndHideLimit(List<Integer> cityIds, int hide, Integer limit);

    List<Hospital> findByNameLike(String name);
}
